*****************************************************
***** Table A2:	Durables, Credit, Borrowing and Lending
*****************************************************


use "$dir/Data/analysis_expenditure.dta", clear


eststo clear
foreach x in durable spending_new_loan{
	gen temp1 =`x' if postpay_3d==1
	egen temp2 = total(temp1), by(pid)
	eststo: reghdfe temp2 cash blhrprod_miss canget1k_miss ownland_miss bs_labor_7_miss bs_labor_30_miss future_fin_worry_miss if pid1==1, cluster(pid) a(roundgroup)
	qui summarize temp2 if cash==0 & pid1==1
	qui estadd scalar cont = r(mean)
	qui estadd local blcont "N"
	drop temp*
}

foreach x in borrow lent{
	eststo: reghdfe `x' cash blhrprod_miss canget1k_miss ownland_miss bs_labor_7_miss bs_labor_30_miss future_fin_worry_miss if pid1==1, cluster(pid) a(roundgroup)
	qui summarize `x' if cash==0 & pid1==1
	qui estadd scalar cont = r(mean)
	qui estadd local blcont "N"
}


#delimit ;
local tablerow cash;

esttab using "$oa/$t/Table_A2.tex", 
    b(2) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles 
    replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
    stats(cont N, labels("Control group mean" "N: workers") fmt(%9.2fc %9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
	\begin{tabular}     
	{@{\extracolsep{5pt}}l*{8}{>{\centering\arraybackslash}m{3.4cm}}@{}}    
	\toprule   \addlinespace                   
	&\multicolumn{1}{c}{Expenditure on}  &\multicolumn{1}{c}{Expenditures}  &\multicolumn{1}{c}{Borrowing} &\multicolumn{1}{c}{Lending} \\
	&\multicolumn{1}{c}{Durable Goods}  &\multicolumn{1}{c}{Taken on Credit}  &\multicolumn{1}{c}{at Worksite} &\multicolumn{1}{c}{at Worksite}  \bigstrut       \\ 
	 ") ;
		
#delimit cr	
